package com.android.smsmb.mui;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.Toast;
import com.android.smsmb.mui.builder.OperationsHandler;

/**
 * Created by andrew on 7/11/14.
 */
public class Actions extends Fragment {

    OperationsHandler operationsHandler;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        final View rootView = inflater.inflate(R.layout.actrions_fragment_action_grid, container, false);

        ImageButton btnBal = (ImageButton)rootView.findViewById(R.id.btnBalance);
        btnBal.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                operationsHandler = new OperationsHandler();
                operationsHandler.setOperation("getBalance");
                selectCard();
                Toast.makeText(getActivity().getApplicationContext(), operationsHandler.getOperation(), Toast.LENGTH_SHORT).show();
            }
        });

        ImageButton btnReplMobTel = (ImageButton)rootView.findViewById(R.id.btnReplenishMobTel);
        btnReplMobTel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                operationsHandler = new OperationsHandler();
                operationsHandler.setOperation("moneyTransfer");
                selectCard();

                Toast.makeText(getActivity().getApplicationContext(), "2", Toast.LENGTH_SHORT).show();
            }
        });

        // ПЕРЕВОД ДЕНЕГ НА ДРУГУЮ КАРТУ
        ImageButton btnMoneyTransfer = (ImageButton)rootView.findViewById(R.id.btnMoneyTransfer);
        btnMoneyTransfer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                operationsHandler = new OperationsHandler();
                operationsHandler.setOperation("send");
                selectCard();
                Toast.makeText(getActivity().getApplicationContext(), "3", Toast.LENGTH_SHORT).show();
            }
        });

        // ЗАБЛОКИРОВАТЬ КАРТУ
        ImageButton btnBlockCard = (ImageButton)rootView.findViewById(R.id.btnBlockCard);
        btnBlockCard.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                operationsHandler = new OperationsHandler();
                operationsHandler.setOperation("blockCard");
                selectCard();
                Toast.makeText(getActivity().getApplicationContext(), "4", Toast.LENGTH_SHORT).show();
            }
        });

        // РАЗБЛОКИРОВАТЬ КАРТУ
        ImageButton btnUnblockCard = (ImageButton)rootView.findViewById(R.id.btnUnblockCard);
        btnUnblockCard.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                operationsHandler = new OperationsHandler();
                operationsHandler.setOperation("unblockCard");
                selectCard();
                Toast.makeText(getActivity().getApplicationContext(), "5", Toast.LENGTH_SHORT).show();
            }
        });

        return rootView;
    }

    public void selectCard(){
        Intent intent = new Intent(getActivity().getApplicationContext(), CardMenuActivity.class);
        startActivity(intent);
    }
}